unit Checkers.CellLabel;

interface

uses
  Classes,
  VectorGeometry,
  GLScene,
  GLState,
  GLRenderContextInfo,
  GLHUDObjects,
  GLContext,
  OpenGLTokens;

type
  TCellLabel = class(TGLAbsoluteHUDText)
  protected
    procedure RenderTextAtPosition(const X, Y, Z: Single;
      var rci: TRenderContextInfo); override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure DoRender(var ARci: TRenderContextInfo; ARenderSelf: Boolean;
      ARenderChildren: Boolean); override;
  end;

implementation

{ TCellLabel }

constructor TCellLabel.Create(AOwner: TComponent);
begin
  inherited;
end;

procedure TCellLabel.DoRender(var ARci: TRenderContextInfo; ARenderSelf,
  ARenderChildren: Boolean);
begin
//  inherited;
  RenderTextAtPosition(0, 0, 0, ARci);
end;

procedure TCellLabel.RenderTextAtPosition(const X, Y, Z: Single;
  var rci: TRenderContextInfo);
var
  vMatrix: TMatrix;
begin
  if Assigned(FBitmapFont) and (Text <> '') then
  begin
    GL.MatrixMode(GL_MODELVIEW);
    GL.PushMatrix;
    vMatrix := rci.PipelineTransformation.ModelViewMatrix;
    GL.LoadMatrixf(@vMatrix);
    GL.MatrixMode(GL_PROJECTION);
    GL.PushMatrix;
    vMatrix := rci.PipelineTransformation.ProjectionMatrix;
    GL.LoadMatrixf(@vMatrix);
    FBitmapFont.RenderString(rci, Text, FAlignment, FLayout,
      FModulateColor.Color);
    GL.PopMatrix;
    GL.MatrixMode(GL_MODELVIEW);
    GL.PopMatrix;
  end;
end;

end.
